/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1618062238797_5268';

  // add your middleware config here
  config.middleware = [ 'jwtauthor' ];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };


  // 关闭crfs token
  config.security = {
    csrf: {
      enable: false,
      ignoreJSON: true,
    },
<<<<<<< HEAD
    domainWhiteList: [ 'http://127.0.0.1:5500','http://localhost:8080','http://localhost:8081' ],
=======
    domainWhiteList: [ 'http://127.0.0.1:5500','http://127.0.0.1:8080','http://localhost:8080' , 'http://localhost:8081','http://localhost:8082' ,],
>>>>>>> a50dad618172b995a66dc2eafec1b49a06352ab9
  };

   // 设置cors配置
   config.cors = {
    // 允许携带cookie数据
    credentials: true,
    // origin: '*',
    // 允许请求方式
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  };
  
  // mysql连接配置
  config.mysql = {
    // database configuration
    client: {
      // host 连接mysql数据库服务器的IP
      host: 'localhost',
      // port  mysql的端口
      port: '3306',
      // username 登录mysql的用户名
      user: 'root',
      // password   登录mysql的用户名对应的密码
      password: 'root',
      // database  登录mysql后选择那个实例
      database: 'xg',
    },
  };

   // 配置cookies信息
   config.cookieOptions = {
    // cookies 事项 将配置做成公共变量
    maxAge: 60 * 1000,
    httpOnly: true,
    encrypt: true, // 对cookies加密

  };


  // 配置 jwt 加密时的秘钥
  config.jwt = {
    secret: '007',
    exp: '7d' //有效期60秒
  };
  
  // 配置session信息
  config.session = {
    // session 事项 将配置做成公共变量
    key: 'EGG_SESS_LOGIN',
    maxAge: 1000000 * 360,
    httpOnly: true,
    encrypt: true, // 对cookies加密
  };

  return {
    ...config,
    ...userConfig,
  };
};
